#include "SliderCtrl.h"

CSliderCtrl::CSliderCtrl()
{
}

CSliderCtrl::~CSliderCtrl()
{
}

HWND CSliderCtrl::Create(HWND hParentWnd, RECT& rc, UINT uID, DWORD dwCtrlStyle, DWORD dwStyle)
{
   HWND hWnd = ::CreateWindowEx( 
        0,                                          // no extended styles 
        TRACKBAR_CLASS,                             // class name 
        NULL,                                       // title (caption) 
        dwStyle | dwCtrlStyle,                      // style 
        rc.left, rc.top,                            // position 
        rc.right - rc.left, rc.bottom - rc.top,     // size 
        hParentWnd,                                 // parent window 
        (HMENU)uID,                                        // control identifier 
        _Module.GetModuleInstance(),                // instance 
        NULL );                                     // no WM_CREATE parameter

   Attach(hWnd);
   return m_hWnd;      
}


void CSliderCtrl::SetRange(WORD wMin, WORD wMax, BOOL bRedraw)
{
    assert (::IsWindow(m_hWnd));
    SendMessage(m_hWnd, TBM_SETRANGE, (WPARAM)bRedraw, (LPARAM) MAKELONG(wMin,wMax)); 
}

void CSliderCtrl::SetPos(WORD wPos, BOOL bRedraw)
{
    assert (::IsWindow(m_hWnd));
    SendMessage(m_hWnd, TBM_SETPOS, (WPARAM)bRedraw, (LPARAM) wPos); 
}

UINT CSliderCtrl::SetPageSize(UINT wPageSize)
{
    assert (::IsWindow(m_hWnd));
    return SendMessage(m_hWnd, TBM_SETPAGESIZE, (WPARAM)0, (LPARAM) wPageSize); 
}

UINT CSliderCtrl::GetPos()
{
    assert (::IsWindow(m_hWnd));
    return SendMessage(m_hWnd, TBM_GETPOS, 0, 0);
}